// ***** This file is automatically generated from SequencesJoinFactory.java.jpp

package daikon.derive.binary;

import daikon.*;

import java.util.logging.Logger;
import java.util.logging.Level;

/**
 * Factory for SequencesJoin derived variables.
 **/
public final class SequencesJoinFactoryFloat extends BinaryDerivationFactory {

  /** Debug tracer. **/
  public static final Logger debug =
    Logger.getLogger("daikon.derive.binary.SequencesJoinFactoryFloat");

  public BinaryDerivation /*@Nullable*/ [] instantiate(VarInfo var1, VarInfo var2) {

    boolean enabled = SequencesJoinFloat.dkconfig_enabled;
    if (!enabled) return null;

    if (!(var1.rep_type.isArray()) ||
        !(var2.rep_type.isArray())) {
      return null;
    }

    if (!var1.aux.getFlag(VarInfoAux.HAS_ORDER) ||
        !var2.aux.getFlag(VarInfoAux.HAS_ORDER)) {
      // Order doesn't matter, then joining is meaningless
      return null;
    }

    /*    if (!(var1.rep_type == ProglangType.INT_ARRAY)  ||
           !(var2.rep_type == ProglangType.INT_ARRAY)) return null;
    */

    if (var1.derived != null || var2.derived != null) {
      // From derived variables.  Don't derive.
      return null;
    }

    if (var1.name().equals(var2.name())) return null;

    if (!var1.is_field() || !var2.is_field())
      return null;

    if (!var1.has_same_parent (var2))
      return null;

    // Now we finally can derive

    if (debug.isLoggable(Level.FINE)) {
      debug.fine (var1.ppt + ": " + var1.name() + " and " +
                   var2.name() + " are worth deriving from");
    }

    return new BinaryDerivation[] {
      new SequencesJoinFloat (var1, var2),
    };
  }

}
